<?php $this->headLink()->appendStylesheet($this->baseUrl('css/forum.css'))?>
<script>
    function ShowHide(tBodyId,img)
    {
	var e =document.getElementById(tBodyId);
	if(e.style.display === 'none')
	{
            e.style.display = 'table-row-group';
            img.src="<?php echo $this->baseUrl('images/collapse.gif'); ?>";
	}
	else
	{
            e.style.display = 'none';	
            img.src="<?php echo $this->baseUrl('images/expand.gif'); ?>";
        }
    }
</script>
<!-- Logo + Breadcrump -->
    <a href="<?php echo $this->url(array('controller'=>'forum','action'=>'index'));?>">
        <img src="<?php echo $this->baseUrl('images/forum_logo.png'); ?>" alt="Forum-Home"/>
    </a>
    <ul class="breadcrumb">You are here : 
        <li class='active'>
            Home
        </li>
    </ul> 
<!-- End of Logo + Breadcrump -->
<!-- Category Tables  -->
<?php for ($i=0;$i<count($this->cats);$i++){?>
    <table class="table table-bordered table-hover" >
	<thead>
            <tr>
                <th style="width:50%">
                    <img class="btn btn-xs" onclick="ShowHide('<?php echo $this->cats[$i]["cat_id"]?>',this)" src='<?php echo $this->baseUrl('images/collapse.gif'); ?>' alt=""><?php echo $this->cats[$i]["name"];?></th>
		<th>threads</th>
		
		<th><span>Latest post</span></th>
            </tr>
	</thead>
        
	<tbody id='<?php echo $this->cats[$i]["cat_id"]; ?>'>
            <?php foreach ($this->cats[$i]['sections'] as $keys => $values){?>
            <tr>
                <td><a href="<?php echo $this->url(array('controller'=>'forum','action'=>'section','id'=>$values['id']));?>"><?php echo $values["sec_name"]; ?></a><br/><?php echo $values["description"]; ?></td>
                <td><center><span class="badge"><?php echo $values["topicsno"][0]['count(*)']; ?></span></center></td>
                <td>
                    <span><dfn>Last post </dfn><a href="<?php echo $this->url(array('controller'=>'forum','action'=>'topic','id'=>$values["latest"][0]["id"])); ?>"><?php echo ($values["latest"][0]['Subject'] ? $values["latest"][0]['Subject'] : 'No topics'); ?></a>
                    <br/><?php echo $values["latest"][0]['CreatedDate']; ?></span>
                </td>
            </tr>
            <?php } ?>
	</tbody>
    </table>
        <?php } ?>
<!-- Category Tables  -->